package nl.sodeso.cubicex.command.storage;

import java.util.Map;

import org.cubictest.selenium.custom.IElementContext;

import com.thoughtworks.selenium.Selenium;

import nl.sodeso.cubicex.CubicExBaseTestCase;

/**
 * Replaces the <code>getAllWindowNames</code> command of SeleniumIDE
 * 
 * @author y.bittan
 * @since 0.0.4
 */
public class StoreAllWindowNames extends CubicExBaseTestCase{

	/**
	 * {@inheritDoc}
	 */
	public void executeTest(Map<String, String> arguments,
			IElementContext context, Selenium selenium) throws Exception {

		final String _variable = getArgVariable();

		String[] array=selenium.getAllWindowNames();

		int i; 
		int n=array.length;

		String res="";

		for (i=0; i<n; i++){
			if (i==n-1){
				res+=array[i];	
			}else{
				res+=array[i] +",";
			}
		}

		context.put(_variable, res);

	}

}
